from django.contrib import admin
from .models import Holiday, Employee, ShiftType, MonthlySchedule, Shift

# 定义管理员类
class HolidayAdmin(admin.ModelAdmin):
    list_display = ('name', 'date', 'is_workday')
    list_filter = ('is_workday',)
    search_fields = ('name',)
    ordering = ('-date',)

class EmployeeAdmin(admin.ModelAdmin):
    list_display = ('name', 'position', 'preferred_shift', 'monthly_rest_days')
    list_filter = ('position',)
    search_fields = ('name',)

class ShiftTypeAdmin(admin.ModelAdmin):
    list_display = ('name', 'code', 'start_time', 'end_time')
    ordering = ('start_time',)

class MonthlyScheduleAdmin(admin.ModelAdmin):
    list_display = ('employee', 'month')
    list_filter = ('month',)
    search_fields = ('employee__name',)
    ordering = ('-month',)

class ShiftAdmin(admin.ModelAdmin):
    list_display = ('employee', 'shift_type', 'shift_date', 'monthly_schedule')
    list_filter = ('shift_type', 'monthly_schedule')
    search_fields = ('employee__name',)
    ordering = ('-shift_date',)

# 注册模型和对应的管理员类


from django.contrib import admin
from .models import Employee, ShiftType, MonthlySchedule, Shift

@admin.register(Employee)
class EmployeeAdmin(admin.ModelAdmin):
    list_display = ('name', 'position', 'preferred_shift', 'monthly_rest_days')
    list_filter = ('position',)
    search_fields = ('name',)

@admin.register(ShiftType)
class ShiftTypeAdmin(admin.ModelAdmin):
    list_display = ('name', 'code', 'start_time', 'end_time')
    ordering = ('start_time',)

@admin.register(MonthlySchedule)
class MonthlyScheduleAdmin(admin.ModelAdmin):
    list_display = ('employee', 'month')
    list_filter = ('month',)
    search_fields = ('employee__name',)
    ordering = ('-month',)

@admin.register(Shift)
class ShiftAdmin(admin.ModelAdmin):
    list_display = ('employee', 'shift_type', 'shift_date', 'monthly_schedule')
    list_filter = ('shift_type', 'monthly_schedule')
    search_fields = ('employee__name',)
    ordering = ('-shift_date',)
